<%-- 
    Document   : updateProfile
    Created on : Jun 28, 2013, 4:45:16 PM
    Author     : Anna SAELEE
--%>

<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link type="text/css" rel="stylesheet" href="style.css"/>
        <title>Vos informations</title>
    </head>
    <% Connection conn;
        Statement stmt;
        ResultSet rs;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/dormitorymanagement", "root", "root");
            stmt = conn.createStatement();%>
    <body>
        <div class="wrapper">
            <div class="header"></div>
            <div class="navigator"> <a href="#">MENU</a> > <a href="#">SUBMENU</a> 30*1000 </div>
            <div class="workspace">
                <%@include file="connect.jsp" %>
                <div class="workspace2">
                    <% if (session.getAttribute("username") != null) {
                            String username = request.getParameter("username");
                            String change = request.getParameter("getChange");
                            if (username.equals("admin")) {%>
                    Connectez-vous comme le membre de système, s'il vous plaît!
                    <% } else {
                        if (change.equals("changePwd")) {%>
                    <h3>Mettre à jour votre mot de passe</h3><br/>
                    <form name="changePwd" method="post" action="Update">
                        <input type="hidden" name="typeMss" value="changePwd"/>
                        <input type="hidden" name="username" value="<%= username%>"/>
                        <table border="0" width="100%">
                            <tr>
                                <th>Votre ancien mot de passe: </th>
                                <td><input type="password" name="oldPwd"/></td>
                            </tr>
                            <tr>
                                <th>Nouvelle mot de passe: </th>
                                <td><input type="password" name="newPwd1"/></td>
                            </tr>
                            <tr>
                                <th>Répétez la nouvelle mot de passe: </th>
                                <td><input type="password" name="newPwd2"/></td>
                            </tr>
                            <tr>
                                <td colspan="2" style="text-align: center">
                                    <input type="submit" value="Soumettre la nouvelle mot de passe" name="updatePwd" />
                                </td>
                            </tr>
                        </table>
                    </form>
                    <% } else if (change.equals("changeMail")) {%>
                    <h3>Mettre à jour votre courriel</h3><br/>
                    <form name="changeMail" method="post" action="Update">
                        <input type="hidden" name="typeMss" value="changeMail"/>
                        <input type="hidden" name="username" value="<%= username%>"/>
                        <table border="0" width="100%">
                            <tr>
                                <th>Nouvelle courriel: </th>
                                <td><input type="text" name="newMail1"/></td>
                            </tr>
                            <tr>
                                <th>Répétez la nouvelle courriel: </th>
                                <td><input type="text" name="newMail2"/></td>
                            </tr>
                            <tr>
                                <th>Votre mot de passe pour confirmer: </th>
                                <td><input type="password" name="password"/></td>
                            </tr>
                            <tr>
                                <td colspan="2" style="text-align: center">
                                    <input type="submit" value="Soumettre la nouvelle courriel" name="changeMail" />
                                </td>
                            </tr>
                        </table>
                    </form>
                    <% }
                        }
                    } else {%>
                    Connectez-vous avant, s'il vous plaît!
                    <% }%>
                </div>
                <%@include file="sidespace.jsp" %>
            </div>
            <div class="footer"> FOOTER 80*1000 </div>
        </div>
    </body>
    <% } finally {
            out.close();
        }%>
</html>